package com.jotton.sampleV16.Fragments;



import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class WebActivity extends WebViewFragment {
	private static final String TAG = WebActivity.class.getName();
	private final String url;

	public WebActivity() {
		this(null);
	}

	public WebActivity(String url) {
		this.url = url;
	}
	
	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		Log.d(TAG, "onAttach: visible=" + isVisible());
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.d(TAG, "onCreate: visible=" + isVisible());
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		Log.d(TAG, "onCreateView: visible=" + isVisible() + " savedInstanceState=" + savedInstanceState);
		return super.onCreateView(inflater, container, savedInstanceState);
	}

	@Override
	public void onActivityCreated(Bundle bundle) {
		super.onActivityCreated(bundle);
		if (url != null) {
			Log.d(TAG, "onActivityCreated: visible=" + isVisible());
	        WebView wv = getWebView();
	        WebSettings setting = wv.getSettings();
	        setting.setJavaScriptEnabled(true);
	        wv.setWebViewClient(new WebViewClient());
			wv.loadUrl(url);
		}
	}

	@Override
	public void onStart() {
		super.onStart();
		Log.d(TAG, "onStart: visible=" + isVisible());
	}

	@Override
	public void onResume() {
		super.onResume();
		Log.d(TAG, "onResume: visible=" + isVisible());
	}

	@Override
	public void onPause() {
		super.onPause();
		Log.d(TAG, "onPause: visible=" + isVisible());
	}

	@Override
	public void onStop() {
		super.onStop();
		Log.d(TAG, "onStop: visible=" + isVisible());
	}

	@Override
	public void onDestroyView() {
		super.onDestroyView();
		Log.d(TAG, "onDestroyView: visible=" + isVisible());
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		Log.d(TAG, "onDestroy: visible=" + isVisible());
	}

	@Override
	public void onDetach() {
		super.onDetach();
		Log.d(TAG, "onDetach: visible=" + isVisible());
	}
}
